package com.tool4j.tools;

import com.tool4j.util.ConversionUtil;
import org.springframework.ai.tool.annotation.Tool;

/**
 * 格式转换工具
 */
public class ConversionTool {

    @Tool(name = "yaml2Properties", description = "仅支持将Yaml转换为Properties格式，不支持XML、JSON、SQL、实体类")
    public String yaml2Properties(String yml) {
        String result = ConversionUtil.castToProperties(yml);
        result = String.format("```properties \n %s \n```", result);
        return result.replace("\n", "\n\n");
    }

    @Tool(name = "properties2Yaml", description = "仅支持将Properties转换为Yaml格式，不支持XML、JSON、SQL、实体类")
    public String properties2Yaml(String properties) {
        String result = ConversionUtil.castToYaml(properties);
        result = String.format("```yaml \n %s \n```", result);
        return result.replace("\n", "\n\n");
    }
}
